package japidviews._tags;
import java.util.*;
import java.io.*;
import cn.bran.japid.tags.Each;
import models.Ingredient.Unit;
import static play.templates.JavaExtensions.*;
import static cn.bran.play.JapidPlayAdapter.*;
import static play.data.validation.Validation.*;
import japidviews._layouts.*;
import play.i18n.Messages;
import play.data.validation.Validation;
import play.mvc.Scope.*;
import models.*;
import play.data.validation.Error;
import play.i18n.Lang;
import japidviews._tags.*;
import play.mvc.Http.*;
import controllers.*;
import japidviews._javatags.*;
//
// NOTE: This file was generated from: japidviews/_tags/count.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class count extends cn.bran.play.JapidTemplateBase
{
	public static final String sourceTemplate = "japidviews/_tags/count.html";
	{
		putHeader("Content-Type", "text/html; charset=utf-8");
		setContentType("text/html; charset=utf-8");
	}

// - add implicit fields with Play

	final Request request = Request.current(); 
	final Response response = Response.current(); 
	final Session session = Session.current();
	final RenderArgs renderArgs = RenderArgs.current();
	final Params params = Params.current();
	final Validation validation = Validation.current();
	final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
	final play.Play _play = new play.Play(); 

// - end of implicit fields with Play 


	public count() {
		super(null);
	}
	public count(StringBuilder out) {
		super(out);
	}
/* based on https://github.com/branaway/Japid/issues/12
 */
	public static final String[] argNames = new String[] {/* args of the template*/"number", "unit",  };
	public static final String[] argTypes = new String[] {/* arg types of the template*/"Float", "Unit",  };
	public static final Object[] argDefaults= new Object[] {null,null, };
	public static java.lang.reflect.Method renderMethod = getRenderMethod(japidviews._tags.count.class);

	{
		setRenderMethod(renderMethod);
		setArgNames(argNames);
		setArgTypes(argTypes);
		setArgDefaults(argDefaults);
		setSourceTemplate(sourceTemplate);
	}
////// end of named args stuff

	private Float number; // line 2
	private Unit unit; // line 2
	public cn.bran.japid.template.RenderResult render(Float number,Unit unit) {
		this.number = number;
		this.unit = unit;
		long t = -1;
		try {super.layout();} catch (RuntimeException e) { super.handleException(e);} // line 2
		return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners, sourceTemplate);
	}
	@Override protected void doLayout() {
		beginDoLayout(sourceTemplate);
//------
;// line 1
;// line 2
		    boolean printUnit = false;// line 4
		    String count = null;// line 5
		if (number % 1 == 0) {// line 6
		        count = String.valueOf(number.intValue());// line 7
		        printUnit = true;// line 8
		    } else {// line 9
		if (unit == Unit.PCS && number == 0.5) {// line 10
		            count = "половинка";// line 11
		        } else {// line 12
		            count = String.valueOf(number);// line 13
			        printUnit = true;// line 14
		        }// line 15
		    }// line 16
		    p(count);// line 18
		if (printUnit) {// line 19
		    	p(" ");// line 20
		if (unit == Unit.GRAM) {// line 22
		            p("г");// line 23
		        } else if (unit == Unit.PCS) {// line 24
		            p("шт.");// line 25
		        } else if (unit == Unit.TABLESPOON) {// line 26
		            p("ст.л.");// line 27
		        } else if (unit == Unit.TEASPOON) {// line 28
		            p("ч.л");// line 29
		        } else if (unit == Unit.GLASS) {// line 30
		            p(number == 1 ? "стакан" : "стакана");// line 31
		        }// line 32
		        ;// line 33
		    }// line 35
		;// line 36
		
		endDoLayout(sourceTemplate);
	}

}